package com.ctvit.cch.core.pojo.dto.base;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.util.Objects;

import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotNull;

/**
 * 分页参数
 *
 * @author heyingcheng
 * @date 2025/07/23
 */
@Getter
@Setter
@ToString
public class PageDTO {

    /**
     * 页码
     */
    @NotNull(message = "当前页码不能为空")
    @Min(value = 1, message = "当前页码不能小于1")
    protected Integer pageNum;

    /**
     * 每页数量
     */
    @NotNull(message = "每页数量不能为空")
    @Min(value = 1, message = "每页数量不能小于1")
    @Max(value = 10000, message = "每页数量不能大于1000")
    protected Integer pageSize;

    public PageDTO() {
        this.pageNum = 1;
        this.pageSize = 20;
    }

    public PageDTO(Integer pageNum, Integer pageSize) {
        this.pageNum = pageNum;
        this.pageSize = pageSize;
    }

    public Integer getPageNum() {
        return Objects.isNull(pageNum) ? 1 : pageNum;
    }

    public Integer getPageSize() {
        return Objects.isNull(pageSize) ? 20 : pageSize;
    }

}
